/*
 * Created by SharpDevelop.
 * User: Dario
 * Date: 15-11-2006
 * Time: 14:34
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace GAH
{
	/// <summary>
	/// Description of ayudaRamos.
	/// </summary>
	public partial class ayudaRamos
	{
		private TextBox pramo;
		private TextBox pasig;
		string projectActual;
		int index;
		int Fila;
		
		public string Ramo{
			set { this.pramo.Text = value;}
			get { return this.pramo.Text;}
		}
		public string Asig{
			set { this.pasig.Text = value;}
			get { return this.pasig.Text;}
		}
						
		public ayudaRamos(ref TextBox Ramo,ref TextBox Asig,ref string project)
		{
			this.pramo  = Ramo;
			this.pasig  = Asig;
			projectActual	= project;
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		void DataGrid1Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
		{
			
		}
		
		void ayudaRamosLoad(object sender, System.EventArgs e)
		{
			negocio neg = new negocio();
			
			MySqlDataReader reader = neg.select("SELECT * FROM ramo where Proyecto='"+projectActual+"'");
		   	
	   		Grilla.Columns.Add("colRamo"  	, "Codigo");
	   		Grilla.Columns.Add("colAsig"   	, "Asignatura");
	   		int Fila = 0;
	   		
		   	while (reader.Read())	
		   	{
		   		Grilla.Rows.Add();
		   		// Profesor
		   		Grilla.Rows[Fila].Cells[0].Value = reader["Ramo"].ToString();
		   		// Nombre
		   		Grilla.Rows[Fila].Cells[1].Value = reader["Descripcion"].ToString();
		   		Fila++;
		   	}
		   	neg.cerrar();
		}
		
		void GrillaCellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
		{
			negocio neg = new negocio();
			
			Fila    = e.RowIndex;
			index	=Fila;
			//Ramo
			string ram	= Grilla.Rows[Fila].Cells[0].Value.ToString();
			//Descripcion
			string des		= Grilla.Rows[Fila].Cells[1].Value.ToString();
						
			string 	query="";
					query += "select * ";
					query += "from ramo ";
					query += "where ";
					query += "Ramo='"+ram+"' "; 
					query += "and Proyecto='"+projectActual+"' ";
						
		   			MySqlDataReader reader  = 	neg.select(query);
	      			
	      		
	      	if(reader.Read())
	      	{
			//Ramo
			this.pramo.Text	= reader["Ramo"].ToString();
			//Descripcion
			this.pasig.Text	= reader["Descripcion"].ToString();
		   	}
	      	neg.cerrar();
			this.Close();
		}
	}
}
